﻿<Page x:Class="CAION2.Views.SelectStigmaPage"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:viewModels="clr-namespace:CAION2.ViewModels"
      xmlns:controls="clr-namespace:CAION2.Controls">

    <Page.DataContext>
        <viewModels:SelectStigmaDialogViewModel />
    </Page.DataContext>

    <Page.Resources>
        <viewModels:IconConverter x:Key="IconConverter" />
        <viewModels:ItemTypeColorConverter x:Key="ItemTypeColorConverter"/>
        <viewModels:StigmaToolTipCreatorConverter x:Key="StigmaToolTipCreatorConverter" />
        
        <ToolTip x:Key="StigmaToolTip">
            <controls:StigmaToolTip DataContext="{Binding Path=[name], Converter={StaticResource StigmaToolTipCreatorConverter}, 
                                                                                        Mode=OneWay,                                 
                                                                                        UpdateSourceTrigger=PropertyChanged}"/>
        </ToolTip>
        
    </Page.Resources>

    <ListBox HorizontalContentAlignment="Left"
                VerticalAlignment="Stretch"
                IsSynchronizedWithCurrentItem="True"
                ItemsSource="{Binding StigmasList}"
                ScrollViewer.HorizontalScrollBarVisibility="Disabled"
                ScrollViewer.VerticalScrollBarVisibility="Auto"
                SelectedItem="{Binding SelectedStigma,
                                    Mode=TwoWay,
                                    UpdateSourceTrigger=PropertyChanged}">
        <ListBox.ItemsPanel>
            <ItemsPanelTemplate>
                <UniformGrid Columns="3" />
            </ItemsPanelTemplate>
        </ListBox.ItemsPanel>

        <ListBox.ItemTemplate>
            <DataTemplate>

                <StackPanel Orientation="Horizontal"
                            Width="250"
                            ToolTipService.ShowDuration="36000"
                            ToolTip="{StaticResource StigmaToolTip}">

                    <Border Width="32"
                            Height="32"
                            Margin="0,0,5,0"
                            BorderThickness="1"
                            BorderBrush="{Binding Path=[quality], Converter={StaticResource ItemTypeColorConverter}}">

                        <Image Source="{Binding Path=[skillicon_name], Converter={StaticResource IconConverter}}"
                           Width="30"
                           Height="30"
                           Stretch="Uniform"/>
                    </Border>
                    
                    <TextBlock Text="{Binding Path=[translate]}"
                               Width="190"
                               TextWrapping="Wrap"
                               VerticalAlignment="Stretch" />
                </StackPanel>
            </DataTemplate>
        </ListBox.ItemTemplate>
    </ListBox>
    
</Page>